package com.jt.advice;

import com.jt.vo.SysResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author :Colin
 * @version 创建时间: 2021/8/8 14:48
 */
/*@ControllerAdvice*/
@RestControllerAdvice//定义全局异常的处理类,返回值是json串

public class MyExceptionAdvice {
    /*写法1:运行时异常--通用 RuntimeException
     2.自定义异常信息
    * 3.拦截所有的异常Exception.class*/
    @ExceptionHandler(RuntimeException.class)
    public Object exception(Exception e){
        e.printStackTrace();
        return SysResult.fail();
    }
}
